package com.aspose.cells;

import java.util.HashMap;

class zajm {
   private zoz a = null;
   private zbpx b;
   private int c;
   private static final com.aspose.cells.b.c.a.za d = new com.aspose.cells.b.c.a.za(new String[]{"fontId", "alignment", "type", "left", "center", "distributed", "noControl", "fullwidthKatakana", "halfwidthKatakana", "Hiragana", "noConversion", "sb", "eb"});

   zajm(zoz var1) {
      this.a = var1;
      this.b = this.a.a.getWorksheets().g;
   }

   void a(zcfw var1) throws Exception {
      this.d(var1);
      if (!var1.n()) {
         this.c = 0;
         var1.d();

         while(zass.a(var1)) {
            var1.j();
            if (var1.r() != 1) {
               var1.a();
            } else if ("si".equals(var1.p())) {
               zayy var2 = null;
               if (var1.n()) {
                  var1.a();
                  var2 = new zayy("", 0);
               } else {
                  var2 = a(var1, this.a.a.getWorksheets(), this.a.d());
               }

               this.b.b(var2, this.c);
               ++this.c;
            } else {
               var1.a();
            }
         }

      }
   }

   zayy b(zcfw var1) throws Exception {
      zayy var2 = a(var1, this.a.a.getWorksheets(), this.a.d());
      var2 = this.b.a(var2.c);
      return var2;
   }

   static zayy a(zcfw var0, WorksheetCollection var1, HashMap var2) throws Exception {
      if (var0.n()) {
         var0.a();
         return new zayy("", 0);
      } else {
         String var3 = null;
         StringBuilder var4 = null;
         short[] var5 = null;
         int var6 = 0;
         zatu var7 = null;
         var0.d();

         while(true) {
            zats var8;
            while(zass.a(var0)) {
               var0.j();
               if (var0.r() != 1) {
                  var0.a();
               } else if ("t".equals(var0.p()) && !var0.n()) {
                  var0.c(c(var0));
                  var3 = var0.i();
                  var0.c(false);
               } else if ("r".equals(var0.p()) && !var0.n()) {
                  if (var4 == null) {
                     var4 = new StringBuilder();
                     var5 = new short[2];
                  } else if (var6 * 2 >= var5.length) {
                     short[] var15 = new short[var6 * 2 + 50];
                     System.arraycopy(var5, 0, var15, 0, var5.length);
                     var5 = var15;
                  }

                  a(var0, var4, var6, var5, var1);
                  ++var6;
               } else if ("phoneticPr".equals(var0.p())) {
                  if (var7 == null) {
                     var7 = new zatu();
                  }

                  if (var0.m()) {
                     while(var0.l()) {
                        switch(d.a(var0.p())) {
                        case 0:
                           var7.b = (Integer)var2.get(zase.C(var0.s()));
                           if (var7.b > 3) {
                              ++var7.b;
                           }
                           break;
                        case 1:
                           switch(d.a(var0.s())) {
                           case 3:
                              var7.a(2);
                              continue;
                           case 4:
                              var7.a(0);
                              continue;
                           case 5:
                              var7.a(1);
                              continue;
                           case 6:
                              var7.a(3);
                           default:
                              continue;
                           }
                        case 2:
                           switch(d.a(var0.s())) {
                           case 7:
                              var7.b(0);
                              break;
                           case 8:
                              var7.b(1);
                              break;
                           case 9:
                              var7.b(2);
                              break;
                           case 10:
                              var7.b(3);
                           }
                        }
                     }

                     var0.k();
                  }

                  var0.a();
               } else if ("rPh".equals(var0.p()) && !var0.n()) {
                  if (var7 == null) {
                     var7 = new zatu();
                  }

                  var8 = a(var0, var3 == null ? 0 : var3.length());
                  var7.c.a(var8);
               } else {
                  var0.a();
               }
            }

            if (var7 != null && var7.c.getCount() == 0) {
               var7 = null;
            }

            var8 = null;
            Object var16;
            if (var6 == 0 && var7 == null) {
               if (var3 == null) {
                  var3 = "";
               }

               var16 = new zayy(var3, 0);
            } else {
               byte[] var9 = null;
               if (var6 != 0) {
                  int var10 = 0;
                  int var11 = var6;
                  if (var5[1] == -1) {
                     var11 = var6 - 1;
                     var10 = 1;
                  }

                  var9 = new byte[var11 * 4];

                  for(int var12 = 0; var12 < var11; ++var12) {
                     short var13 = var5[var10 * 2];
                     short var14 = var5[var10 * 2 + 1];
                     ++var10;
                     zase.a(var9, var12 * 4, var13);
                     zase.a(var9, var12 * 4 + 2, var14);
                  }

                  var3 = com.aspose.cells.b.a.zr.a(var4);
               }

               if (var7 != null) {
                  var16 = new zatv(var3, var9, var7);
               } else if (var9 != null) {
                  var16 = new zbap(var3, var9, 0);
               } else {
                  var16 = new zayy(var3, 0);
               }
            }

            return (zayy)var16;
         }
      }
   }

   private static zats a(zcfw var0, int var1) throws Exception {
      if (var0.n()) {
         var0.a();
         return null;
      } else {
         zats var2 = new zats();
         int var3 = 0;
         int var4 = var1 - 1;
         if (var0.m()) {
            while(var0.l()) {
               switch(d.a(var0.p())) {
               case 11:
                  var3 = zase.C(var0.s());
                  break;
               case 12:
                  var4 = zase.C(var0.s());
               }
            }
         }

         var2.a = var3;
         var2.b = var4 - var3 + 1;
         var0.d();

         while(true) {
            while(zass.a(var0)) {
               var0.j();
               if (var0.r() != 1) {
                  var0.a();
               } else if ("t".equals(var0.p()) && !var0.n()) {
                  var0.c(c(var0));
                  String var5 = var0.i();
                  var0.c(false);
                  var2.c = var5;
               } else {
                  var0.a();
               }
            }

            return var2;
         }
      }
   }

   private static void a(zcfw var0, StringBuilder var1, int var2, short[] var3, WorksheetCollection var4) throws Exception {
      if (var0.n()) {
         throw new CellsException(6, "Invalid r element");
      } else {
         short var5 = (short)var1.length();
         zoo var6 = null;
         var0.d();

         while(true) {
            while(zass.a(var0)) {
               var0.j();
               if (var0.r() == 1 && "rPr".equals(var0.p()) && !var0.n()) {
                  var6 = zajp.a(var0, var4, "rFont");
               } else if (var0.r() == 1 && "t".equals(var0.p()) && !var0.n()) {
                  var0.c(c(var0));
                  String var7 = var0.i();
                  var0.c(false);
                  var1.append(zase.b(var7));
               } else {
                  var0.a();
               }
            }

            int var8 = 0;
            if (var2 == 0 && var6 == null) {
               var8 = -1;
            }

            if (var6 != null) {
               var8 = zase.a(var6, var4);
            }

            var3[var2 * 2] = var5;
            var3[var2 * 2 + 1] = (short)var8;
            return;
         }
      }
   }

   static boolean c(zcfw var0) {
      String var1 = var0.a("space", (String)null);
      return var1 != null;
   }

   private void d(zcfw var1) throws Exception {
      var1.j();
      if (var1.r() != 1 || !"sst".equals(var1.p())) {
         throw new CellsException(6, "SharedStringTable root element eror");
      }
   }
}
